home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
intrvews
/
xgrab.lha
/
xgrab
/
grabst
/
set.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-03-06
|
2KB
|
98 lines
/**
GRAB Graph Layout and Browser System
Copyright (c) 1986, 1988 Regents of the University of California
Copyright (c) 1989, Tera Computer Company
**/
/* set.c -- routines for set manipulations. */
#include "attribute.h"
#include "digraph.h"
BOOL empty();
BOOL equal();
BOOL empty(set)
SET *set;
/* empty returns TRUE if set is empty. */
{
int i; /* counter */
if (set->first == (MAXNODES - 1) && set->last == 0)
{
return(TRUE);
}
/* otherwise, is FALSE, but check anyway (for now) */
for (i = 0; i < MAXBYTES; i++)
{
if (set->bytes[i])
{
return(FALSE);
}
}
/* the following statement should never be reached */
return(TRUE);
} /* empty */
BOOL equal(set1, set2)
SET *set1, *set2;
/* equal returns TRUE if set1 and set2 have the same elements. */
{
int i; /* counter */
if ((set1->first != set2->first) || (set1->last != set2->last))
{
return(FALSE);
}
for (i = 0; i < MAXBYTES; i++)
{
if (set1->bytes[i] != set2->bytes[i])
{
return(FALSE);
}
}
return(TRUE);
} /* equal */
card(set)
SET *set;
/* card returns the cardinality of set. */
{
int i; /* each element */
int count; /* counter */
count = 0;
each_element(set, i)
loop
count++;
endloop
return(count);
} /* card */
print_set_elements(set)
SET *set;
/* print_set_elements prints the elements of a set */
{
int i;
printf("first = %d , last = %d\n", set->first, set->last);
printf("elements: ");
for (i = 0; i < MAXNODES; i++)
{
if (in(set, i))
{
printf("%d ", i);
}
}
printf("\n");
} /* print_set_elements */